import { request } from '@/utils'

export function getBlogById(id) {
  return request({
    url: '/admin/getBlogById',
    method: 'GET',
    params: {
      id,
    },
  })
}

export function saveBlog(Blog) {
  return request({
    url: '/admin/saveBlog',
    method: 'POST',
    data: JSON.stringify(Blog),
    headers: {
      'Content-type': 'application/json;charset=utf-8',
    },
  })
}

export function updateBlogVisibility(Blog) {
  return request({
    url: '/admin/updateBlogVisibility',
    method: 'POST',
    data: JSON.stringify(Blog),
    headers: {
      'Content-type': 'application/json;charset=utf-8',
    },
  })
}

export function getBlogList(BlogListDTO) {
  return request({
    url: '/admin/getBlogList',
    method: 'POST',
    data: JSON.stringify(BlogListDTO),
    headers: {
      'Content-type': 'application/json;charset=utf-8',
    },
  })
}

export function deleteBlogById(id) {
  return request({
    url: '/admin/deleteBlogById',
    method: 'POST',
    params: {
      id,
    },
  })
}

export function publishBlog(id, isPublished) {
  return request({
    url: '/admin/publishBlog',
    method: 'POST',
    params: {
      id,
      isPublished,
    },
  })
}

export function topBlog(id, isTop) {
  return request({
    url: '/admin/topBlog',
    method: 'POST',
    params: {
      id,
      isTop,
    },
  })
}
